//
//  ZH_ScheduleTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/30.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_ScheduleTableViewCell.h"
@interface ZH_ScheduleTableViewCell()
@property (nonatomic,weak)UIView *lineView;
@property (nonatomic,weak)UILabel *numLabel;
@property (nonatomic,weak)UILabel *nameLabel;
@property (nonatomic,weak)UILabel *typeLabel;
@property (nonatomic,weak)UILabel *beginLabel;
@property (nonatomic,weak)UILabel *endLabel;
@property (nonatomic,weak)UIButton *detailButton;
@end
@implementation ZH_ScheduleTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_ScheduleTableViewCell";
    ZH_ScheduleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_ScheduleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
    self.topLongLineImage.hidden = NO;
    self.bottomLongLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(18));
        make.left.equalTo(self.contentView).offset(FITSCALE(12));
        make.height.mas_equalTo(FITSCALE(17));
        make.width.mas_equalTo(FITSCALE(1));
    }];
    [self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.lineView);
        make.left.equalTo(self.lineView.mas_right).offset(FITSCALE(8));
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.numLabel);
        make.top.equalTo(self.numLabel.mas_bottom).offset(FITSCALE(10));
    }];
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(FITSCALE(10));
    }];
    [self.beginLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.top.equalTo(self.typeLabel.mas_bottom).offset(FITSCALE(10));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-14));
    }];
    [self.detailButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.lineView);
        make.right.equalTo(self.contentView).offset(FITSCALE(-12));
        make.width.mas_equalTo(FITSCALE(75));
        make.height.mas_equalTo(FITSCALE(25));
    }];
}
#pragma mark - getter,setter
- (UIView *)lineView{
    if (!_lineView) {
        UIView *view = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#00C9AE"]];
        [self.contentView addSubview:_lineView = view];
    }
    return _lineView;
}
- (UILabel *)numLabel{
    if (!_numLabel) {
        UILabel *label = [UILabel createLabelWithText:@"课程一" font:kFontSize_26];
        [self.contentView addSubview:_numLabel = label];
    }
    return _numLabel;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        UILabel *label = [UILabel createLabelWithText:@"课程名称: 英语基础" font:kFontSize_26];
        [self.contentView addSubview:_nameLabel = label];
    }
    return _nameLabel;
}
- (UILabel *)typeLabel{
    if (!_typeLabel) {
        UILabel *label = [UILabel createLabelWithText:@"课程类型: 线下" font:kFontSize_26];
        [self.contentView addSubview:_typeLabel = label];
    }
    return _typeLabel;
}
- (UILabel *)beginLabel{
    if (!_beginLabel) {
        UILabel *label = [UILabel createLabelWithText:@"开课时间: 2018-10-11 14: 00: 00" font:kFontSize_26];
        [self.contentView addSubview:_beginLabel = label];
    }
    return _beginLabel;
}
- (UILabel *)endLabel{
    if (!_endLabel) {
        UILabel *label = [UILabel createLabelWithText:@"结束时间: 2018-10-11 14: 00: 00" font:kFontSize_26];
        [self.contentView addSubview:_endLabel = label];
    }
    return _endLabel;
}
- (UIButton *)detailButton{
    if (!_detailButton) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"查看详情" target:self action:nil];
        button.backgroundColor = [UIColor colorWithHexString:@"#00C9AE"];
        [button setTitleColor:kFontColorWhite forState:UIControlStateNormal];
        button.layer.cornerRadius = FITSCALE(12);
        button.layer.masksToBounds = YES;
        button.clipsToBounds = YES;
        button.titleLabel.font = kFontSize_28;
        [self.contentView addSubview:_detailButton = button];
    }
    return _detailButton;
}
@end
